<?php
class DBMEntityManagerFactory {
	/**
	 * The connection manager instance
	 *
	 * @var DBMConnectionManager
	 */
	private static $connectionManager = null;
	
	/**
	 * Create a new entity manager 
	 *
	 * @param string $connectionID
	 * @return DBMEntityManager
	 */
	public static function createEntityManager($connectionID = "default"){
		// check the connection manager instance
		if(self::$connectionManager == null){
			self::$connectionManager = DBMConnectionManager::getInstance();
		}
		
		// get the connection
		$connection = self::$connectionManager->getConnection($connectionID);
		
		// create the entity manager
		$entityManager = new DBMEntityManager($connection);
		
		// return
		return $entityManager;
	}
	
	/**
	 * Create a new entity manager (alias to self::createEntityManager) 
	 *
	 * @param string $connectionID
	 * @return DBMEntityManager
	 */
	public static function create($connectionID = "default"){
		return self::createEntityManager($connectionID);
	}
}

?>